﻿// /////////////////////////////////// 
//  
//  
//      WiseLink CCF2.0 
//     (c)Copyright 2001-2010 WiseLink Xiaojun (David) Chen 
//        Authored and Owned Xiaojun (David) Chen 
//        All Right Reserved
//  
// /////////////////////////////////// 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WiseLink.RDS.Model;
using WiseLink.Infrastructure.Common.EntityFramework;

namespace WiseLink.RDS.Model
{
    partial class Vehicle
    {
        private int _urgentCount;
        
        
        public global::System.Int32 UrgentCount
        {
            get
            {
                CCF20Entities ccf20Ent = (CCF20Entities)this.GetContext();
                _urgentCount = ccf20Ent.Faults.Where(f => f.IsActive && f.FaultType == "撞车" && f.VehicleID == this.VehicleID).Count();
                return _urgentCount;
            }
            set
            {
                if (_urgentCount != value)
                {
                    _urgentCount = value;
                }
            }

        }

        public global::System.Int32 ConfirmedFaultCount
        {
            get
            {
                CCF20Entities ccf20Ent = new CCF20Entities();
                return ccf20Ent.Faults.Where(f => f.IsActive && f.FaultType == "故障" && f.VehicleID == this.VehicleID && f.IsConfirmed).Count();
            }

        }
        public global::System.Int32 FaultCount
        {
            get
            {
                CCF20Entities ccf20Ent = new CCF20Entities();
                return ccf20Ent.Faults.Where(f => f.IsActive && f.FaultType == "故障" && f.VehicleID == this.VehicleID).Count();
            }

        }

        public global::System.Int32 UnConfirmedFaultCount
        {
            get
            {
                CCF20Entities ccf20Ent = new CCF20Entities();
                return ccf20Ent.Faults.Where(f => f.IsActive && f.FaultType == "故障" && f.VehicleID == this.VehicleID && !f.IsConfirmed).Count();
            }

        }
        public global::System.Int32 MaintenanceCount
        {
            get
            {
                CCF20Entities ccf20Ent = new CCF20Entities();
                return ccf20Ent.VehicleMaintenanceHistories.Where(f => f.IsActive && f.VehicleID == this.VehicleID).Count();
            }

        }
        string _SMSStatus = "未发送";
        public global::System.String SMSStatus
        {
            get
            {
                CCF20Entities ccf20Ent = new CCF20Entities();
                int count = ccf20Ent.SMSHistories.Where(s => s.IsActive && s.VehicleID == this.VehicleID).Count();
                if (count > 0)
                    _SMSStatus = "已发送";
                return _SMSStatus;
            }

        }
        public Vehicle()
        {


        }


    }
}
